
library ieee;
use ieee.std_logic_1164.all;
use work.mystd.all;

entity KMBRANCH is 
	port (
    	aluBranch	: in std_logic;		-- ako je u pitanju skok prilikom izvrsavanje instrukcije uslovnog skoka
    	counterValue: in bus8;			-- vrednost brojaca upravljacke jedinice
       	 
    	kmbranchOUT	: out bus8;			-- vrednost counter-a ako dodje do skoka
    	branch		: out std_logic	-- upravljacki signal kojim se azurira vrednost countera
	); 
     
end KMBRANCH;     
        

architecture KMBRANCH of KMBRANCH is
begin  
		-- adresa skoka kojim se azurira brojac koraka ako dodje do skoka
		-- svi su bezuslovni skovi sem jednog ** if(aluBranch == 0) skok();
		kmbranchOUT <= X"2C" 
					when 
						(
						   counterValue = X"0A" OR counterValue = X"0F" OR counterValue = X"12" OR
						   counterValue = X"15" OR counterValue = X"18" OR counterValue = X"1B" OR
						   counterValue = X"1E" OR counterValue = X"21" OR counterValue = X"25" OR
						   counterValue = X"27"	OR (counterValue = X"23" AND aluBranch = '0') or counterValue = X"2A"
						) else X"00";
					
		branch	<= '1' 			
				   when (
						   counterValue = X"0A" OR counterValue = X"0F" OR counterValue = X"12" OR
						   counterValue = X"15" OR counterValue = X"18" OR counterValue = X"1B" OR
						   counterValue = X"1E" OR counterValue = X"21" OR counterValue = X"25" OR
						   counterValue = X"27"	OR counterValue = X"2F" OR (counterValue = X"23" AND aluBranch = '0')
						   or counterValue = X"2A"
						) else '0';
						
end KMBRANCH;








